<?php
/**
 * User: hufeng
 * Date: 2016/12/18
 * Desc: 游戏类型Model
 */

namespace Model;
use Think\Model;

class AdminCustomerModel extends Model{
    protected $connection = 'DB_SERVE';
    protected $tableName = 'admin_customer';

    //查询单条记录
    public function findData($where){
        $re = $this->where($where)->find();
        return $re;
    }

    //查询多条记录
    public function selectData($where,$fields='*'){
        $re = $this->field($fields)->where($where)->select();
        return $re;
    }

    //更新记录
    public function editData($where,$data){
        $re = $this->where($where)->save($data);
        return $re;
    }

    //添加
    public function addData($data){
        $re = $this->add($data);
        return $re;
    }

    /*筛选数据*/
    public function search($param,$page,$pernum,$sortStr='id desc',$exportxls=false){
        if($exportxls){
            $res = $this->where($param)->order($sortStr)->select();
        }else{
            $res = $this->where($param)->order($sortStr)->limit($pernum)->page($page)->select();
        }
        return $res;
    }

    public function getTotalNum($param){
        return $this->where($param)->count();
    }

    public function sumData($field,$where){
        return $this->where($where)->sum($field);
    }
}